From: kfraser@localhost.localdomain Date: Fri, 28 Jul 2006 16:35:39 +0000 (+0100) Subject: [XEND] Better checking of shutdown of domain0. X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~15768 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=87f45629c696175f7a8047ce2e25af8427ec2f31;p=xen.git [XEND] Better checking of shutdown of domain0. Signed-off-by: Masaki Kanno --- diff --git a/tools/python/xen/xend/XendDomainInfo.py b/tools/python/xen/xend/XendDomainInfo.py index 0d97fe38ac..35a014900d 100644 --- a/tools/python/xen/xend/XendDomainInfo.py +++ b/tools/python/xen/xend/XendDomainInfo.py @@ -943,6 +943,8 @@ class XendDomainInfo: def shutdown(self, reason): if not reason in shutdown_reasons.values(): raise XendError('Invalid reason: %s' % reason) + if self.domid == 0: + raise XendError("Can't specify Domain-0") self.storeDom("control/shutdown", reason) diff --git a/tools/python/xen/xm/shutdown.py b/tools/python/xen/xm/shutdown.py index a72ec74f5b..7c974f80a9 100644 --- a/tools/python/xen/xm/shutdown.py +++ b/tools/python/xen/xm/shutdown.py @@ -23,8 +23,6 @@ from xen.xend.XendClient import server from xen.xend import sxp from xen.xm.opts import * -DOM0_ID = '0' - gopts = Opts(use="""[options] [DOM] Shutdown one or more domains gracefully. @@ -51,14 +49,6 @@ gopts.opt('reboot', short='R', use='Shutdown and reboot.') def shutdown(opts, doms, mode, wait): - if doms == None: doms = server.xend.domains(0) - dom0_name = sxp.child_value(server.xend.domain(0), 'name') - for x in [dom0_name, DOM0_ID]: - if x in doms: - if opts.vals.all: - doms.remove(x) - else: - opts.err("Can't specify Domain-0") for d in doms: server.xend.domain.shutdown(d, mode) if wait: @@ -86,8 +76,11 @@ def shutdown_mode(opts): return 'poweroff' def main_all(opts, args): + doms = server.xend.domains(0) + dom0_name = sxp.child_value(server.xend.domain(0), 'name') + doms.remove(dom0_name) mode = shutdown_mode(opts) - shutdown(opts, None, mode, opts.vals.wait) + shutdown(opts, doms, mode, opts.vals.wait) def main_dom(opts, args): if len(args) == 0: opts.err('No domain parameter given')